package JavaBasics;

/**
 * Created by IntelliJ IDEA.
 * User: Stas
 * Date: 12.10.12
 * Time: 19:23
 * To change this template use File | Settings | File Templates.
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class NeighbouringNumbers {

    /**
     * @param args
     */
    public static void main(String[] args) {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String inputString = null;

        try {
            inputString = br.readLine();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.out.print("Index : "+findNeighboringNumbers(getArrayFromString(inputString)));
    }

    public static int findNeighboringNumbers(int[] inputValue) {
        int indexOfFirstNumber = 0;
        int smallestDistance = Math.abs(inputValue[1] - inputValue[2]);
        int currentDistance = 0;
        for(int i=0; i < inputValue.length-1; i++) {
            currentDistance = Math.abs(inputValue[i] - inputValue[i+1]);
            if(currentDistance < smallestDistance)
                indexOfFirstNumber = i;
        }

        return indexOfFirstNumber;
    }

    public static int[] getArrayFromString(String inputString) {
        String[] inputStringArray = inputString.split(" ");
        int[] resultArray = new int[inputStringArray.length];

        for(int i=0; i<resultArray.length; i++) {
            resultArray[i] = Integer.parseInt(inputStringArray[i]);
        }

        return resultArray;
    }

}

